<template>
	<view class="leave_list">
		<view class="main">
			<view class="ul">
				<view v-for="(item, index) in initData" :key="index">
					<view class="li" @click="go_detail(item.id)">
						{{ item.content }}
						<uni-icons type="arrowright" size="24" class="right" color="#999" />
					</view>
				</view>
			</view>
			<view v-show="initData.length==0" class="notavailable">
				<image src="../../../static/img/notavailable.png" mode="widthFix"></image>
				<view class="nottext">暂时没有数据</view>
			</view>
			<view class="go-top" v-show="is_go_top" @click="backTop"><image src="/static/img/go_top.png" /></view>
		</view>
	</view>
</template>

<script>
import { uniIcons } from '@dcloudio/uni-ui';
import leave from '../../../servers/my/leave.js';
export default {
	components: { uniIcons },
	data() {
		return {
			is_go_top: false,
			initData: [],
			paging: {
				page: 1,
				total: 10
			}
		};
	},
	onPageScroll: function(e) {
		//nvue暂不支持滚动监听，可用bindingx代替
		if (e.scrollTop > 200) {
			this.is_go_top = true;
		} else {
			this.is_go_top = false;
		}
	},
	mounted() {
		this.getData();
	},
	methods: {	
		getData(){
		var obj={currentPage:this.paging.page, pageSize: 10}
			leave
				.initData()
				.then(res => {
					this.initData = res.data.records;
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
			
		},
		go_detail(id) {
			this.commonality.route_baling('/pages/shop/my/leave','shopleave',id)
		},
		backTop() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 200
			});
		}
	},
	onPullDownRefresh() {
	        console.log('refresh');
	        setTimeout(function () {
				this.paging.page += 1;
				this.getData();
	            uni.stopPullDownRefresh();
				
	        }, 1000);
	    }
};
</script>

<style lang="less" scoped>
.leave_list {
	height: 100%;
	.main {
		// position: absolute;
		// top: 80rpx;
		// bottom: 0;
		// width: 100%;
		// overflow: auto;
		background: #fff;
		.ul {
			padding: 0 20rpx;
			.li {
				position: relative;
				line-height: 113rpx;
				font-size: 30rpx;
				padding-right: 50rpx;
				border-bottom: 1rpx solid #e1e1e1; /*no*/
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				.right {
					position: absolute;
					top: 0;
					right: 0;
				}
			}
		}
	}
}
</style>
